<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<script type="text/javascript">
function butById(regId)
{
	 //alert( document.form.action+"----"+regId);
	 document.form.regId.value=regId;
	 //alert(document.getElementById("regId").value);
	 document.form.submit();
}
</script>
<body>
<form name='form' method='POST' action='sendAll'>
<input type="hidden"  name="regId"  id="regId"  value=""/>

<%
List<String> devices=(List<String>)request.getAttribute("devices");
if(devices==null)
{
	%><h2>No devices registered!</h2><%
}
else
{
	%>
	<table border="1"  width="40%">
		<tr>
			<td>regId</td>
			<td>imei</td>
			<td>account</td>
			<td>Operation</td>
		</tr>
		
			<%
			for(int i=0;i<devices.size();i++)
			{
			%>
			<tr>
			<td><%=devices.get(i) %></td>
			<td>imei</td>
			<td>account</td>
			<td>
			<input  type='button' value='Send Message'  onclick="butById('<%=devices.get(i) %>');"/></td>
			</tr>
			<%
			}
			%>
		
	</table>

	<h2><%=devices.size() %> device(s) registered!</h2>
	<input type='submit' value='Send Message ALL' /><%
}
%>
</form>

</body>
</html>